<!-- welcome.html -->
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>欢迎</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f4f4f4;
        }
        .container {
            max-width: 400px;
            margin: 100px auto;
            padding: 20px;
            background-color: #fff;
            border-radius: 5px;
            box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
        }
        h2 {
            text-align: center;
            color: #333;
        }
        ul {
            list-style-type: none;
            padding: 0;
        }
        li {
            padding: 5px 0;
        }
        .logout {
            text-align: center;
            margin-top: 20px;
        }
        button {
            padding: 10px;
            background-color: #007bff;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
<div class="container">
    <h2>欢迎</h2>
    <p>在线名单：</p>
    <ul id="online-users">
        <!-- 这里使用 JavaScript 动态生成在线名单 -->
    </ul>
    <div class="logout">
        <button onclick="logout()">退出登录</button>
    </div>
</div>
<script>
        // 检查用户是否已登录，如果未登录则跳转回登录页面
        var loggedInUser = localStorage.getItem('loggedInUser');
        if (!loggedInUser) {
            window.location.href = 'login11.html';
        }

        // 显示在线名单
        var onlineUsersList = document.getElementById('online-users');
        var li = document.createElement('li');
        li.textContent = loggedInUser;
        onlineUsersList.appendChild(li);

        // 退出登录
        function logout() {
            localStorage.removeItem('loggedInUser');
            window.location.href = 'login11.html';
        }
    </script>
</body>
</html>
